package com.utils.basejava.concurrent.lock;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class LockUsrCase {

	public static void main(String[] args) {
		Lock lock = new ReentrantLock();
		
		lock.lock();
		try {
			
		} finally {
			lock.unlock();
		}
		
		lock.newCondition();//获取等待通知组件
		try {
			lock.lockInterruptibly();//可中断获取锁
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		lock.tryLock();//尝试非阻塞获取锁
		try {
			lock.tryLock(100l, TimeUnit.SECONDS);//超时的获取锁
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
